package com.hspedu.collection_;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class CollectionE {

    public static void main(String[] args) {
        @SuppressWarnings({"all"})
        Dog dog = new Dog("jack", 10);
        Dog dog1 = new Dog("tom", 30);
        Dog dog2 = new Dog("jerry", 60);
        List dogs = new ArrayList(10);
        dogs.add(dog);
        dogs.add(dog1);
        dogs.add(dog2);
        Iterator iterator = dogs.iterator();
        while (iterator.hasNext()) {
            Object next =  iterator.next();
            System.out.println(next);
        }
        for (Object o :dogs) {
            System.out.println(o);
        }
    }
}

class Dog{
    private String name;
    private int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}